<template>
  <div>
    <div id="nav">
      <div class="logo">糯米</div>
      <router-link :to="{ path: '/search' }">
        <div class="search">
          <div class="search-icon">
            <img src="../../assets/search-icon.png" alt="" />
          </div>
          <div class="search-input">
            <input type="text" name="" placeholder="搜一搜" />
          </div>
        </div>
      </router-link>
    </div>
    <div id="banner">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(image, index) in images" :key="index">
          <img :src="image.url" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div id="icon-list">
      <div class="icon-list-box">
        <img src="../../assets/index_03.png" alt="" />
        <p>上新精选</p>
      </div>
      <div class="icon-list-box">
        <img src="../../assets/index_05.png" alt="" />
        <p>小米众筹</p>
      </div>
      <div class="icon-list-box">
        <img src="../../assets/index_07.png" alt="" />
        <p>有品秒杀</p>
      </div>
      <div class="icon-list-box">
        <img src="../../assets/index_09.png" alt="" />
        <p>生活优选</p>
      </div>
      <div class="icon-list-box">
        <img src="../../assets/index_11.png" alt="" />
        <p>小米自营</p>
      </div>
    </div>
    <div id="content">
      <Content></Content>
    </div>
  </div>
</template>

<script>
import { getBannerList } from "@/api/home";
import Content from "@/components/showGoods.vue";
export default {
  components: { Content },
  name: "Home",
  data() {
    return {
      images: [],
      productList: [],
    };
  },

  async created() {
    // 测试了一下，可删
    let res = await getBannerList();
    let { resultCode, resultInfo } = res.data;
    if (resultCode == 1) {
      this.images = resultInfo.list;
    }
  },

  methods: {},
};
</script>

<style lang="less" scoped>
#nav {
  height: 56px;
  width: 100%;
  display: flex;
  background-color: #845d32;
  .logo {
    width: 60px;
    height: 100%;
    font-size: 24px;
    line-height: 56px;
    text-align: center;
    color: white;
  }
  .search {
    width: 304px;
    height: 32px;
    line-height: 56px;
    border-radius: 15px;
    display: flex;
    .search-icon {
      border-top-left-radius: 15px;
      border-bottom-left-radius: 15px;
      width: 40px;
      height: 100%;
      border: none;
      background-color: white;
      margin-top: 12px;
      margin-left: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 14px;
        height: 14px;
      }
    }
    .search-input {
      input {
        width: 264px;
        height: 32px;
        border: none;
        border-top-right-radius: 15px;
        border-bottom-right-radius: 15px;
      }
    }
  }
}
#banner {
  .van-swipe {
    width: 100%;
    height: 160px;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
#icon-list {
  height: 80px;
  width: 100%;
  background-color: #f4f4f4;
  display: flex;
  justify-content: space-evenly;
  .icon-list-box {
    margin-top: 15px;
    width: 50px;
    height: 60px;
    text-align: center;
    .img {
      width: 36px;
      height: 36px;
    }
    p {
      margin-top: 10px;
      font-size: 12px;
      color: #4da0df;
    }
  }
}
#content {
  margin-top: 20px;
}
</style>
